#encoding: utf-8
from django import forms
from apps.xfzauth.forms import FormMixin
from apps.news.models import News
from apps.news.models import Banner
from apps.course.models import Course

class EditNewsCategoryForm(forms.Form):
    pk = forms.IntegerField(error_messages={'require':'必须传入分类的ID！'})
    name = forms.CharField(max_length=100)

class WriteNewsForm(forms.ModelForm,FormMixin):
    category = forms.IntegerField()
    class Meta:
        model = News
        # 除去不需要的字段
        exclude = ['pub_time','category','author']

class EditNewsForm(forms.ModelForm,FormMixin):
    category = forms.IntegerField()
    pk = forms.IntegerField()
    class Meta:
        model = News
        # 除去不需要的字段
        exclude = ['pub_time','category','author']

class AddBannerForm(forms.ModelForm,FormMixin):
    class Meta:
        model = Banner
        fields = ['priority','image_url','link_to']

class EditBannerForm(forms.ModelForm,FormMixin):
    pk = forms.IntegerField()
    class Meta:
        model = Banner
        fields = ['image_url','link_to']

class PubCourseForm(forms.ModelForm,FormMixin):
    category_id = forms.IntegerField()
    teacher_id = forms.IntegerField()
    class Meta:
        model = Course
        exclude = ['category','teacher']